;var containedStickyScroll = new Class({
	
	Implements: [Options],
	
	options: {
		speed: 400
	},
	
	initialize: function(container,options) {
		/* initial options */
		this.setOptions(options);
		this.container = container;
		this.container.setStyle('position', 'relative');

		this.fx = new Fx.Morph(this.container, {
			'duration': this.options.speed,
			'link': 'cancel'
		} );
		
		/* start listening */
		this.startListeners();
	},
	
	startListeners: function() {
		
		var action = function() {
					
			if ( this.getDocumentScrollTop() > this.container.getParent().getPosition().y &&
				(this.container.getParent().getSize().y + this.container.getParent().getPosition().y - 30) > (this.getDocumentScrollTop() + this.container.getSize().y) ) {

				this.fx.start( {'top': this.getDocumentScrollTop() - this.container.getParent().getPosition().y } );

			} else if ( this.getDocumentScrollTop() < this.container.getParent().getPosition().y ) {

				this.fx.start( {'top': 0 } );

			}
		}.bind(this);

		window.addEvent('scroll', action);
		
	},

	getDocumentScrollTop: function (doc) 
	{
		doc = doc || document;

		//doc.body.scrollTop is IE quirkmode only
		return Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
	}
});
